package revir;
import java.util.*;
import java.util.Scanner;
    public class maple {
        public static void main(String[] args) {
            // Create a HashMap
            Map<String, Integer> hashMap = new HashMap<>();
            hashMap.put("小明", 20210301);
            hashMap.put("小李", 20210302);
            hashMap.put("李华", 20210303);
            hashMap.put("小美", 20210304);

            System.out.println("显示学生信息");
            System.out.println(hashMap + "\n");

            // Create a TreeMap from the preceding HashMap
            Map<String, Integer> treeMap = new TreeMap<>(hashMap);
            System.out.println("Display entries in ascending order of key");
            System.out.println(treeMap);

            // Create a LinkedHashMap
            Map<String, Integer> linkedHashMap =
                    new LinkedHashMap<>(16, 0.75f, true);
            linkedHashMap.put("小明", 20210301);
            linkedHashMap.put("小李", 20210302);
            linkedHashMap.put("李华", 20210303);
            linkedHashMap.put("小美", 20210304);

            // Display the age for Lewis
            System.out.println("小明的学号是" +
                    linkedHashMap.get("小明"));

            System.out.println("Display entries in LinkedHashMap");
            System.out.println(linkedHashMap);

            // Display each entry with name and age
            System.out.print("显示姓名和学号:"+ "\n");
            treeMap.forEach(
                    (name, age) -> System.out.print(name + ": " + age + " "));
            Scanner m1 = new Scanner(System.in);
            System.out.println("请输入学号"+"\n");
            int ID = m1.nextInt();
            if (ID == 20210301){
                System.out.println("小明");
            } else if (ID == 20210302) {
                System.out.println("小李");
            } else if (ID == 20210303) {
                System.out.println("李华");
            } else if (ID == 20210304) {
                System.out.println("小美");
            }else {
                System.out.println("请输入正确的学号"+"\n");
            }
        }
    }

